package test;

//二叉搜索树中第k小的数：https://leetcode.cn/problems/kth-smallest-element-in-a-bst/
public class KthSmallest {
	public static int count;
    public static int ret;
    public void dfs(TreeNode root)
    {
        if(root==null||count<1) return ;
        dfs(root.left);
        count--;
        if(count==0) ret=root.val;
        dfs(root.right);
        
    }
    public int kthSmallest(TreeNode root, int k) {
        count=k;
        dfs(root);
        return ret;
    }
}
